const express = require('express')

const router = express.Router()
// 导入用户路由处理函数模块
const artcate_handler = require('../router_handler/artcate')

// 1. 导入验证表单数据的中间件
const expressJoi = require('@escook/express-joi')
// 2. 导入需要的验证规则对象
const {
	add_cate_schema,
	del_cate_schema,
	update_cate_schema
} = require('../schema/artcate')

// 获取文章分类的列表数据
router.get('/cates', artcate_handler.getArticleCates)
// 新增文章分类的路由
router.post('/addcates', expressJoi(add_cate_schema), artcate_handler.addArticleCates)
// 删除文章分类的路由
router.get('/deletecate/:id',expressJoi(del_cate_schema), artcate_handler.deleteCateById)
// 根据 Id 获取文章分类数据
router.get('/cates/:id', expressJoi(del_cate_schema), artcate_handler.getArtCateById)
// 根据 Id 更新文章分类数据
router.post('/updatecate', expressJoi(update_cate_schema), artcate_handler.updateCateById)

module.exports = router